package com.sskj.hhrt.mine;

import com.sskj.base.data.User;
import com.sskj.base.utils.RxUtils;
import com.sskj.hhrt.BasePresenter;
import com.sskj.hhrt.api.Api;
import com.sskj.hhrt.api.ApiObserver;
import com.sskj.hhrt.api.SystemInfo;


/**
 * @author Hey
 * Create at  2019/03/27
 */
class CashOutPresenter extends BasePresenter<CashOutActivity> {

    public void getSystemInfo() {
        Api.getInstance().getSystemInfo("")
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<SystemInfo>(this, true) {
                    @Override
                    public void onSuccess(SystemInfo data) {
                        mView.setSysInfo(data);
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.stopRefresh();
                    }
                });
    }

    public void cashOut(String usdFee) {
        Api.getInstance().cashOut(usdFee)
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<Object>(this, true) {
                    @Override
                    public void onSuccess(Object data) {
                        mView.onPaySuccess();
                    }
                });
    }


    public void getAccountDetail(String account, boolean showLoading) {
        Api.getInstance().accountDetail()
                .compose(RxUtils.transform())
                .subscribe(new ApiObserver<User>(this, showLoading) {
                    @Override
                    public void onSuccess(User data) {
                        mView.setAccountInfo(data);
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mView.stopRefresh();
                    }
                });
    }


}
